from bokeh.driving import count

str_str="!Hello world!"


count_sum=0
pre_end =False
# 记录单词进行时 bool来表示程序的运行状态
word_ing=False
for e in str_str:
    # 看到字母就认为单词开始
    if  (e.isupper() or e.islower()) and not word_ing :
        # 一个新的单词开始了
        count_sum+=1
        word_ing=True
    # 看到非字母就认为单词结束
    elif not (e.isupper() or e.islower()):
        word_ing=False

print(count_sum)


